﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace LorraineSec.DatabaseLib
{
    interface ILibrary
    {
        /// <summary>
        /// Creates and returns a new XmlDocument to use as the xml database.
        /// </summary>
        /// <returns>A new XmlDocument.</returns>
        XmlDocument createNew(String filename);

        /// <summary>
        /// Loads a new .xml file from the passed in filename, replacing any previously loaded file. 
        /// </summary>
        /// <param name="filename">The .xml filename to load.</param>
        void loadNew(String filename);

        /// <summary>
        /// Opens the .xml file at the passed filename. 
        /// 
        /// Throw an exception if a file is already loaded.
        /// </summary>
        /// <param name="filename">The .xml filename to load.</param>
        void load(String filename);

        /// <summary>
        /// Unloads any loaded .xml file. 
        /// </summary>
        void unload();

        /// <summary>
        /// Makes sure that the loaded file contains the required xml tags.
        /// 
        /// Returns true if the loaded file is valid, false otherwise.
        /// </summary>
        /// <returns>True if the loaded file is valid, false otherwise.</returns>
        bool validate();

        /// <summary>
        /// Saves the current changes to the .xml file.
        /// </summary>
        void save();

        /// <summary>
        /// Saves the current changes to a file at the passed in filename. If the file exists, IT WILL BE OVERWRITTEN.
        /// </summary>
        /// <param name="filename"></param>
        void saveAs(String filename);

        /// <summary>
        /// Prints the entire current .xml structure to the Console. 
        /// </summary>
        void printXml();

        /// <summary>
        /// Prints the entire xml structure to the Console starting from the parent element. 
        /// </summary>
        /// <param name="parent">The parent object to print.</param>
        void printXml(XmlElement parent);

        /// <summary>
        /// Prints the XmlNodes in the passed in XmlNodeList. 
        /// </summary>
        /// <param name="list">The collection of XmlNodes to print.</param>
        void printXml(XmlNodeList list);
    }
}
